import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/ui.dart';

class UiResult extends StatelessWidget {
  const UiResult({
    super.key,
    this.text,
    this.icon,
    this.info,
    this.ikon,
    this.height,
    this.width,
    this.onTap,
  });
  final String? text;
  final String? ikon;
  final Widget? icon;
  final Widget? info;
  final double? height;
  final double? width;

  final Function()? onTap;

  @override
  Widget build(BuildContext context) {
    return Container(
      constraints: BoxConstraints(
        maxHeight: MediaQuery.of(context).size.height,
      ),
      child: LayoutBuilder(
        builder: (context, constraints) {
          return UiTap(
            onTap: onTap,
            child: SizedBox(
              height: height ?? constraints.maxHeight - 150,
              child: Center(
                child: SafeArea(
                  bottom: true,
                  top: false,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Opacity(
                        opacity: UiTheme(context).match(light: 1.0, dark: 0.6)
                            as double,
                        child: icon ??
                            Image.asset(
                              'res/images/ikons/${ikon ?? 'record'}.png',
                              width: width ?? 180,
                            ),
                      ),
                      info ??
                          Text(
                            text ?? '暂无数据',
                            style: TextStyle(
                              color: UiTheme(context).matchColor(
                                Colors.black54,
                                Colors.white54,
                              ),
                            ),
                          ),
                    ],
                  ),
                ),
              ),
            ),
          );
        },
      ),
    );
  }
}
